package com.coding.controller;

import com.coding.base.pojo.BaseModel;
import com.coding.base.pojo.PageQueryModel;
import com.coding.service.MainPlaceService;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @auther wangchenghao
 * @date 2020/7/26
 **/
@Controller
@ResponseBody
@RequestMapping("mainplace")
public class MainPlaceController {
    @Autowired
    MainPlaceService mainPlaceService;

    @ApiOperation("搜索栏查询主要景点")
    @RequestMapping(value = "/searchMainPlace", method = {RequestMethod.GET})
    public BaseModel searchMainPlace(@ApiParam("text") @RequestParam(value = "text", required = true) String text) throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.searchMainPlace(text, model);
        return model;
    }

    @ApiOperation("查询浙东唐诗之路主要景点")
    @RequestMapping(value = "/getZd", method = {RequestMethod.GET})
    public BaseModel getzd() throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.getwayplace(1, model);
        return model;
    }

    @ApiOperation("查询大运河诗路主要景点")
    @RequestMapping(value = "/getYh", method = {RequestMethod.GET})
    public BaseModel getyh() throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.getwayplace(2, model);
        return model;
    }

    @ApiOperation("查询钱塘江诗路主要景点")
    @RequestMapping(value = "/getQt", method = {RequestMethod.GET})
    public BaseModel getqt() throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.getwayplace(3, model);
        return model;
    }

    @ApiOperation("查询瓯江山水诗路主要景点")
    @RequestMapping(value = "/getOj", method = {RequestMethod.GET})
    public BaseModel getoj() throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.getwayplace(4, model);
        return model;
    }

    @ApiOperation("查询推荐页轮播图")
    @RequestMapping(value = "/getBanner", method = {RequestMethod.GET})
    public BaseModel getBanner() throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.getBannerPlace(model);
        return model;
    }

    @ApiOperation("传参查看诗路主要景点")
    @RequestMapping(value = "/getWayByKind", method = {RequestMethod.GET})
    public BaseModel getWayByKind(@ApiParam("way_id") @RequestParam(value = "way_id", required = true) Integer way_id) throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.getwayplace(way_id, model);
        return model;
    }

    @ApiOperation("查询推荐页景点列表")
    @RequestMapping(value = "/getRecommendList", method = {RequestMethod.GET})
    public BaseModel getRecommendList(@ModelAttribute PageQueryModel pageQueryModel) throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.getListMainPlace(pageQueryModel, model);
        return model;
    }

    @ApiOperation("根据id查询主要景点信息")
    @RequestMapping(value = "/getMainPlace", method = {RequestMethod.GET})
    public BaseModel getRecommendList(@ApiParam("mainplace_id") @RequestParam(value = "mainplace_id", required = true) Integer mainplace_id) throws Exception {
        BaseModel model = new BaseModel();
        mainPlaceService.getMainPlace(mainplace_id, model);
        return model;
    }
}
